/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.thienloc.omap.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author GiangLT
 */
@Entity
@Table(name = "OMAP_SETTING", catalog = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "OmapSetting.findAll", query = "SELECT o FROM OmapSetting o"),
    @NamedQuery(name = "OmapSetting.findBySettingId", query = "SELECT o FROM OmapSetting o WHERE o.settingId = :settingId"),
    @NamedQuery(name = "OmapSetting.findBySettingKey", query = "SELECT o FROM OmapSetting o WHERE o.settingKey = :settingKey"),
    @NamedQuery(name = "OmapSetting.findBySettingValue", query = "SELECT o FROM OmapSetting o WHERE o.settingValue = :settingValue")})
public class OmapSetting implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "SETTING_ID")
    private Integer settingId;
    @Size(max = 100)
    @Column(name = "SETTING_KEY")
    private String settingKey;
    @Size(max = 100)
    @Column(name = "SETTING_VALUE")
    private String settingValue;
    @OneToMany(mappedBy = "parentId")
    private List<OmapSetting> omapSettingList;
    @JoinColumn(name = "PARENT_ID", referencedColumnName = "SETTING_ID")
    @ManyToOne
    private OmapSetting parentId;

    public OmapSetting() {
    }

    public OmapSetting(Integer settingId) {
        this.settingId = settingId;
    }

    public Integer getSettingId() {
        return settingId;
    }

    public void setSettingId(Integer settingId) {
        this.settingId = settingId;
    }

    public String getSettingKey() {
        return settingKey;
    }

    public void setSettingKey(String settingKey) {
        this.settingKey = settingKey;
    }

    public String getSettingValue() {
        return settingValue;
    }

    public void setSettingValue(String settingValue) {
        this.settingValue = settingValue;
    }

    @XmlTransient
    public List<OmapSetting> getOmapSettingList() {
        return omapSettingList;
    }

    public void setOmapSettingList(List<OmapSetting> omapSettingList) {
        this.omapSettingList = omapSettingList;
    }

    public OmapSetting getParentId() {
        return parentId;
    }

    public void setParentId(OmapSetting parentId) {
        this.parentId = parentId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (settingId != null ? settingId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OmapSetting)) {
            return false;
        }
        OmapSetting other = (OmapSetting) object;
        if ((this.settingId == null && other.settingId != null) || (this.settingId != null && !this.settingId.equals(other.settingId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.thienloc.omap.entity.OmapSetting[ settingId=" + settingId + " ]";
    }
    
}
